Repository navigation
refactor: tools and snapshots over the #1207 memo, edges and contexts (#1207 PR 9) - #1239
Merged
Merged
Conversation
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 9, 2026 10:09
55a1384 to
8a376d3
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
3 times, most recently
from
November 9, 2026 11:12
7354458 to
a9fc990
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 9, 2026 12:37
8a376d3 to
6c01250
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 9, 2026 12:41
a9fc990 to
5ce0b18
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
2 times, most recently
from
November 9, 2026 19:13
a95b905 to
13f5151
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 9, 2026 19:32
5ce0b18 to
fc8aa18
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 9, 2026 21:40
13f5151 to
2166fdf
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 9, 2026 21:47
fc8aa18 to
1d781e2
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 10, 2026 00:02
2166fdf to
db34c43
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 10, 2026 00:06
1d781e2 to
2f63941
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 10, 2026 00:19
db34c43 to
e8a3f73
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 10, 2026 00:19
2f63941 to
fde0945
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 10, 2026 00:49
e8a3f73 to
11e9fe2
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 10, 2026 00:54
fde0945 to
9e7a8a0
Compare
This was referenced Nov 10, 2026
zzylol
force-pushed
the
refactor/1207-accuracy
branch
2 times, most recently
from
November 16, 2026 04:46
3916932 to
55f0ef6
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 16, 2026 05:40
9e0f501 to
afdc971
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 16, 2026 06:56
55f0ef6 to
b8d6ffb
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 16, 2026 07:12
0bc02af to
f2411a9
Compare
zzylol
force-pushed
the
refactor/1207-accuracy
branch
from
November 16, 2026 19:56
b8d6ffb to
593ef41
Compare
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 16, 2026 21:24
f2411a9 to
d744bd7
Compare
This was referenced Nov 16, 2026
… by layer and every pruned candidate with its cause; planner_fuzz costs witnesses over Stage 3's plan; viewer reads the plan; snapshots re-baselined (#1207 PR 9) Ported onto the #1207 layout (main's stage crates, types::stages scopes, plan::physical_asap_dag, accuracy::metric_rule). Removes every todo!("#1207 PR 9") in devtools. - asap_planner text and asap-stage-pipeline/v2: memo groups with their properties (column lineage and sign, evaluation-time dependence, scanned sources, evaluation grid); Pass 2 logical edges with alpha^log and why each fails (Pass 2's chain rule, then ErrorMetricsOfMemo's metric and accuracy rules); Pass 2 eliminated candidates with root-cause traces; Stage 2 physical edges with alpha^phys; Stage 2 and Stage 3 pruned candidates; Stage 3 plan with plan_cost and the MILP's size and objective. Candidates that differ only in theta fold by default; --printing-full-candidates prints everything. - planner_fuzz: witnesses extend Stage 3's PhysicalASAPDAG and are costed by plan_cost; LongerWindow is a TimeRange over the same chain; the accuracy relations are deleted; the #891 regression test now holds. - PruneReason, RootPruneReason and OriginOfCandidateForMemoGroup serialize snake_case; Pass 2 exports chain_off_the_evaluation_grid for the edge reasons. - Viewer reads the new document; its fixture and pins are regenerated. - Corpus and sketch plan snapshots re-baselined.
…from Pass 2; prints materialized views, all group properties; plans MetricsQL (#1207 PR 9, round 1) - Pass 2 records every failing (u, c, i) with the RootPruneReason it computed, eliminated candidates' edges included (LogicalASAPMemoCandidates::failing_logical_edges). asap_planner's text and JSON read it (LogicalEdgeStatus) instead of re-deriving the reason, which disagreed with Pass 2 for readouts whose query has no per-value failure probability. chain_off_the_evaluation_grid is pub(crate) again; devtools no longer depends on asap-accuracy. - Text Stage 3: one line per materialized view (node, refresh, retention); the objective prints as {:.6e}. - Group properties (text and JSON): result_kind, shareable_when_equal and aggregate_coverage. - MetricsQL workloads lower with asap-frontend-metricsql. - #891's test pins the remaining gap against the witness explicitly; the Pass 1 failure document has a unit test again.
…there (#1207 PR 9, rebase onto PR 8 round 1) PR 8 round 1 moved DDSketch's sign check into its guarantee, so a DDSketch quantile over values not of one sign now fails its readout edge with NoGuarantee, as do a randomized sketch under an exact target (δ 0) and HLL. The old text said the summary type has no guarantee for the statistic, which is wrong for all three.
…mbers, no MILP times, sharing summary); adapt to main (#1207 PR 9) The JSON document follows the testing design's printer decisions: - memo group, candidate and physical candidate ids are renumbered depth first from the query roots (CanonicalIds), lists in canonical id order; the text output keeps the planner's ids; - the planner's numbers are rounded to 12 significant digits by the printer (the snapshot tests' own rounding is deleted); - milp_construction_ms, milp_solve_ms and milp_solve_count leave the document (the text prints them, with the solve count); - Stage 3 has a sharing_summary: each plan node two or more queries read. Adapting to main's planner: the viewer drops MaterializedViewInputs' removed raw_data_windows; the viewer fixture plans without raw data so it still reads a KLL chain; three CLI tests take oracles that do not depend on the cost constants; the corpus and sketch snapshots are re-baselined.
…iew fixes (#1207 PR 9) - devtools' serde_json reads floats exactly (float_roundtrip), so the snapshot harness no longer turns 1.87400000613e-12 into 1.8740000061300003e-12; four sketch snapshots regenerated. - PhysicalASAPDAG::root_nodes_per_query holds the query -> plan root rule; sharing_summary_json, planner_fuzz and the test-only query_roots use it. - sharing_summary_json computes each sort key once; query_id names q1, q2. - Text output: "(1 solve)". - User guide: JSON ids are canonical, text ids are the planner's. - #891/#902 fuzz tests' doc comments state the current gap, tracked in #891. - kll-only-capabilities.json renamed kll-only-no-raw-data-capabilities.json.
zzylol
force-pushed
the
refactor/1207-tools
branch
from
November 16, 2026 23:04
d744bd7 to
bd3a333
Compare
zzylol
marked this pull request as ready for review
November 16, 2026 23:04
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
todo!("#1207 PR 9")in devtools:asap_plannerpanics after Stage 3 (and in the Pass 2 and Stage 2 printers), so 58asap-devtoolstests fail on main.planner_fuzzcannot cost a witness, the viewer reads the pre-Tracking: implement the optimization formulation (memo candidates, properties, edges y_{u,c,i}, MILP) as named code per stage #1207 document, and the snapshots were never regenerated from the Tracking: implement the optimization formulation (memo candidates, properties, edges y_{u,c,i}, MILP) as named code per stage #1207 planner. The testing design (docs(proposals): testing infrastructure design and decisions #1353, decisions D1–D4 and D28, tracked in Testing infrastructure: tracking #1354) also asks this printer for a document that can be compared as text.asap_plannertext and theasap-stage-pipeline/v2document print every stage: each memo group with its properties, the logical edges with α^log and, for each failing one, the reason Pass 2 recorded, the candidates Pass 2 eliminated with their root causes, the physical edges with α^phys, Stage 2's and Stage 3's pruned candidates, and the plan withplan_cost, its materialized views and the MILP's size and objective. MetricsQL workloads plan too.planner_fuzzcosts witnesses over Stage 3's plan withplan_cost, and the viewer reads the new document. The JSON document is now stable: canonical memo ids (D1), numbers rounded to 12 significant digits by the printer and read back exactly (D2), no MILP times or solve count (D3), and a Stage 3sharing_summary(D28).asap-devtoolsgoes from 37 passed / 58 failed on main to 93 passed / 3 failed. All 3 failures areplanner_fuzzregression tests that main's cost refits now break (see Follow-ups); none fails because of the printer. Example: for two quantiles over one metric, the document'ssharing_summaryis[{"operator": "Scan", "queries": ["q1", "q2"], "timing": "query_time", ...}]. When a second query over another metric is added, the first query's memo group and candidate ids stay as they were.Review guide
ca4be93f0(includes refactor(stage3): constraint (K) per execution and metric; sign-conditioned DDSketch guarantee, classic HLL certificate from the source's distinct bound (#1207 PR 8) #1238 and fix(stage3, accuracy): name the missed query when the second solve finds no plan; widen accuracy limits relatively only #1376). The PR was retargeted from refactor(stage3): constraint (K) per execution and metric; sign-conditioned DDSketch guarantee, classic HLL certificate from the source's distinct bound (#1207 PR 8) #1238's branch. Earlier heads are kept asbackup/refactor/1207-tools-f2411a9b7andbackup/refactor/1207-tools-d744bd7ae.d744bd7aebefore this rebase) are rebased unchanged ontoca4be93f0(no conflicts; fix(stage3, accuracy): name the missed query when the second solve finds no plan; widen accuracy limits relatively only #1376 changes no snapshot). The last commit holds the final-review fixes (see "Final review fixes").d744bd7ae):crates/devtools/src/stable_output.rs:CanonicalIds,rounded_to_12_significant_digits.crates/devtools/src/bin/asap_planner.rs:canonical_ids_of,memo_groups_json,logical_inputs_json,physical_candidates_json,pruned_candidates_json,pass2_pruned_json,selection_jsonandsharing_summary_json. Also the rounding step inrun.crates/devtools/tests/asap_planner.rs: the two new tests and the three re-oracled ones (see Verification).UPDATE_SNAPSHOTS=1).test-fixtures/p90-kll.jsonis regenerated, and the viewer tests are re-pinned to its canonical ids.Behavior: before → after
The workload: two queries over one gauge,
quantile_over_time(0.5, data[1m])andquantile_over_time(0.9, data[5m]), each every 10 s, on 10,000 series sampled every 15 s.The command:
asap_planner --workload two-quantiles.json --run-until stage3 --ignore-accuracy-guarantees --format json.f2411a9b7)todo!("#1207 PR 9")10.433958721056003)10.4339587211). The input echo (workload.data_workload,deployment_capabilities) stays as given.stage3_plan_selectionkeysmilp_construction_ms,milp_solve_ms,milp_solve_count…selection MILP: 545 variables, 809 constraints, 7 ms building, 60 ms solving (1 solve), objective 1.043396e1/s."sharing_summary": [{"lifetime": {"OneEvaluation": "Memory"}, "operator": "Scan", "parameters": null, "queries": ["q1", "q2"], "timing": "query_time"}]This serves the golden runner in the testing design: one
expected.jsonper case, compared as text.Alignment with the testing design (#1353 D1–D3, D28)
Where #1239 differed from the design, I followed the design, because its author owns test infrastructure.
MemoGroupIds and candidate indicesCanonicalIdsrenumbers groups depth first from each query's root groups, in query order. Below a group it visits the expression's inputs, then each candidate's inputs and fused groups. A group's candidates are ordered by origin and then by operator without its inputs. Physical candidates follow their logical candidate. Every id field in the document uses the canonical ids:id,operator,children,parents,fused_groups,inputs[].group, edgeproducer,selected_candidates,through_pruned_candidates,root.*.consumer,dominated_by, andG<n>insidecolumn_lineageandaggregate_coverage. Lists are in canonical id order. The text output keeps the planner's ids, which logs and error messages use, so no debug flag is needed.corpus_snapshots.rs::roundedroundedroundedis deleted. devtools'serde_jsonhasfloat_roundtrip, so a harness that reads the document back gets the same digits (without it,1.87400000613e-12came back as1.8740000061300003e-12).milp_construction_ms,milp_solve_ms,milp_solve_countin JSON(1 solve)/(N solves)next to the times, soSelection::milp_solve_countstill has a reader. The document has no absolute paths.stage3_plan_selection.sharing_summary: each plan node that two or more queries read, described byoperator,parameters,timing,lifetimeandqueries, with no node id. Sorted by queries, then operator.D4 (the full memo per step,
addedrelative to the step before) was already met. D18 (deterministic small-case solves) belongs to the Stage 3 solver setup, not this printer.Rebase onto main
2f3664d1f(earlier round)git rebase --onto origin/main b8d6ffb04. The one conflict was inasap_planner.rs, against #1365's assumed-fact warnings and #1238'smilp_solve_count. I merged it so that the assumed facts are computed from the oneplan_costthe printer already computes.Main's planner changed under this PR (#1355, #1363, #1365, #1368, and #1238 rounds 2–3). The adaptations are part of
d744bd7ae:a_selected_ddsketch_over_undeclared_magnitudes_is_warned_about(feat(types, cost, planner): warn about each data fact a plan assumes because the workload does not declare it (DDSketch range, in-order arrival) #1365's test, never run on main). Its ad hoc query had arrivalunknownand no raw data kept, so it is infeasible. It is now repeating every 10 s over ingesting data, so the DDSketch chain is selected and the warning is checked.aws_fargate_prices_example_4_in_dollars. The old bound, the whole-window KLL at $2.60e-8/s, assumed the old cost constants. The test now checks that the plan's cost equals its usage at the page's prices: 1.17e8 CPU ops × 1.1244e-14 + 1.07e7 B × 1.1244e-15 + 2.17e7 B × 1.235e-6 / 2^30 = $1.3525e-6/s.a_scan_two_queries_share_is_offered_built_once_per_evaluation. The old bound of ≤ 0.144/s assumed the old scan costs. The test now checks that there is one scan, built once per evaluation and charged for 10,000 × 300 / 15 = 200,000 samples.MaterializedViewInputshas noraw_data_windowson main any more. The check and the views table drop it, and a view's inputs readraw dataorviews ….Final review fixes
serde_json = { version = "1", features = ["float_roundtrip"] }incrates/devtools/Cargo.toml(the only crate whose snapshot or golden path parses the planner's numbers). Snapshots regenerated: only the six 1-ULP lines change (1.8740000061300003e-12→1.87400000613e-12×5 in nested-windows, shared-quantiles and ratio-of-quantiles;5.622000013799999e-15→5.6220000138e-15in topk-rate-guarantees-ignored). A scan of every number incrates/devtools/tests/**/*.jsonandtools/dag-viewer/test-fixtures/*.json(3,787 numbers) finds none above 12 significant digits in any snapshot or fixture; the only longer ones are hand-written workload inputs (0.050000000000000044in three random-mixed workloads,66.66666666666667in the #891 fuzz seed), which the planner does not print.PhysicalASAPDAG::root_nodes_per_query(types, plan scope, non-test).sharing_summary_json,planner_fuzz::operator_treesand the test-onlyquery_rootscall it; their own copies of the rule are deleted.ratio-of-quantiles-1h-mvpmoved to the plan-change rows; the removed-tests table below; the text output prints(1 solve).docs/user_guide_docs/asap-planner.md, "Inspect the result".planner_fuzztestssharing_summary_jsoncomputes each entry's sort text once;query_id(index)replaces the threeformat!("q{}", i + 1);kll-only-capabilities.json→kll-only-no-raw-data-capabilities.json(references in the viewer README,test_viewer.py,memo.test.mjs).in_serialized's shape match is kept (acceptable for devtools).Interfaces
crates/devtools/src/stable_output.rs(new)crates/devtools/src/planning_stages_text.rs. These two helpers were added earlier in this PR. They now name groups throughgroup_id: the text passes the planner's id, the JSON passes the canonical id.asap-stage-pipeline/v2document (stage3_plan_selection, relative tof2411a9b7)"stage3_plan_selection": { "plan": PhysicalASAPDAG, "cost": {...}, + /// Each plan node two or more queries read, by what it computes. + "sharing_summary": [{"operator", "parameters", "timing", "lifetime", "queries"}], "accepted_accuracy_per_query": [...], "pruned_candidates": [...], "milp_variables": u64, "milp_constraints": u64, - "milp_construction_ms": u64, - "milp_solve_ms": u64, - "milp_solve_count": u64, "milp_objective_cost_per_second": f64, "materialized_views": [...] }The three removed keys change from run to run or with the solver (D3); the text output prints them.
crates/types/src/plan/physical_asap_dag.rsimpl PhysicalASAPDAG { + /// Each query's root in node ids, in workload order: query `i` is the + /// scalar root keyed `i` when there is one, and otherwise the next entry + /// of `roots`. Example: `roots = [n4]`, `scalar_roots = [(0, n2 / n3)]` + /// gives `[Scalar(n2 / n3), Operator(n4)]`. + pub fn root_nodes_per_query(&self) -> Vec<QueryRoot<PhysicalASAPNodeId>>; /// (test-only) now `root_nodes_per_query` with each node id replaced by its operator tree. pub fn query_roots(&self) -> Result<Vec<QueryRoot>, PhysicalASAPDAGValidationError>; }Viewer test fixture:
Usage:
Design scope
crates/devtools/src/stable_output.rs(devtools, printer output). It holds what makes a planner document comparable as text: canonical ids and rounding. Any devtools document can use it, not only goldens.CanonicalIds: the same scope. It is a general id renumbering over a memo and its physical candidates, not tied to one test.PhysicalASAPDAG::root_nodes_per_query(types, plan scope). Which plan root answers which query is a property of the plan, stated in the doc ofroots/scalar_roots; every reader that walks the plan per query (printers, fuzzing, tests) needs it.Algorithm changes
None in the planner. The printer's canonical renumbering is described under Alignment. It is linear in the number of memo groups and candidates, plus one sort per group's candidates.
Decisions and open questions
Needs reviewer decision:
Decided (2026-11-16):
workload.data_workloadanddeployment_capabilitiesare what the user gave, sorows_per_second: 66666.66666666667stays as written. D2 names costs and ε/δ, which are the planner's output.--raw-idsflag was added.Kll(k=26),Kll(k=52), …), whose order the rule fixes; its numbers sorted as text would read badly. Rejected: adding θ and the required accuracy to the sort key.milp_solve_countleaves JSON as a solver statistic (D3), and the text prints it.Verification
Head is rebased onto main
ca4be93f0; main isca4be93f0; tests compared by name.cargo test -p asap-devtools(passed / failed / ignored)planner_fuzztests that also fail on main (todo!); see Follow-ups.cargo test -p asap-typescargo test --release -p asap-devtools --test corpus_snapshots -- --ignored(corpus and sketch snapshots, check mode)UPDATE_SNAPSHOTS=1, then checked without it.node --test memo.test.mjs stages.test.mjspython3 -m unittest test_viewer test_servertest-fixtures/p90-kll.jsonreproduces byte-identically from the head binary.cargo fmt --all -- --check;cargo clippy -p asap-devtools -p asap-types --all-targets --all-features -- -D warningsTests on main but not on head. Renamed:
*_witness_prices_*→*_witness_costs_*(10planner_fuzztests),finds_issue_891_…→issue_891_filtered_rate_reads_the_grouped_rate,memo_section_lists_each_step_and_the_selected_choice→…_selected_candidates,pass1_failure_still_writes_stage0_and_the_error→ the bin unit testtests::a_pass1_failure_still_writes_stage0_and_the_error,pass2_holds_a_tumbling_window_candidate_for_every_width_dividing_the_grid→pass2_holds_tumbling_windows_at_the_gcd_of_ranges_and_steps,a_topk_heap_over_one_row_per_item_is_pruned_with_its_reason→…_is_not_offered,snapshot_keeps_the_queries_and_search_status→snapshot_keeps_the_queries,viewer_knows_every_view_refresh_and_rejection_cause→viewer_knows_every_view_refresh,milp_search_objective_equals_plan_cost_on_example1_and_rangeheavy→milp_search_selects_a_plan_on_example1_and_rangeheavy. Deleted, with the reason:milp_lower_bound_is_consistent_with_the_selected_costsearch_report.cost_lower_bound_per_secondandstatus. The #1207Selectionhas no search report, lower bound or status; nothing to check.milp_search_objective_equals_plan_cost_on_example1_and_rangeheavymilp_search_selects_a_plan_on_example1_and_rangeheavy: thestatus == "optimal"andinexact_objectivechecks went with the search report; the plan, MILP size and per-query accuracy checks stay. That the selected plan'splan_costequals what the search selected it for is checked byplanner_fuzz::the_selected_plan_costs_what_the_search_selected_it_for.proven_optimal_needs_an_optimal_statusproven_optimal, which read the deleted search status; the helper is deleted with it.finds_issue_903_looser_accuracy_not_reading_the_exact_resultplanner_fuzz/README.md.generate::tests::accuracy_ladder_stepslooser/tighter, deleted with the accuracy relations.the_document_names_the_selected_logical_candidatestage1_logical_asap_optimization.candidates[].idandfrom_logical: whole-plan logical candidates, which #1207 replaced by per-group memo candidates.memo_section_lists_each_step_and_the_selected_candidateschecks the selected candidates instead.logical_candidate_labels_name_each_querydisplay_name. Which queries share a node is nowsharing_summary, checked bythe_sharing_summary_names_the_nodes_several_queries_read.pass1_failure_comes_before_capabilities_and_keeps_stage3_nulla_pass1_failure_still_writes_stage0_and_the_error.New tests in the alignment round:
memo_ids_of_a_query_do_not_move_when_another_query_is_added(D1). At every step,quantile_over_time(0.9, a[5m])'s groups have the same ids and contents with and without a second query overb. The planner's own ids would fail this at Pass 1.the_sharing_summary_names_the_nodes_several_queries_read(D28, D2). Two quantiles over one metric share aScan(["q1", "q2"]), one query shares nothing, and every number has at most 12 significant digits.stable_output::tests::floats_keep_12_significant_digits(D2).the_search_reports_candidate_connectionschecks the MILP size is present and the three D3 keys are absent.memo_section_lists_each_step_and_the_selected_candidateschecks that children name groups of the step, not that they are below the group count.failing_logical_edges_show_the_reason_pass_2_recordedfinds the readouts in the text by label, because the text keeps the planner's ids.Snapshot changes (against
f2411a9b7's snapshots). Every change comes from main's planner, not from this printer: a snapshot holds no memo ids, and withfloat_roundtripthe harness reads the printer's 12-digit numbers back unchanged. Please confirm the whys:SummaryAgg ExactAggregate + FinalizeExactAccumulatorover the chain's result becomes a hashAggregate; q02 0.4867 → 12.46/s, q06 0.4897 → 15.19/slifetimegoes fromnullto{"OneEvaluation": "Memory"}, plus new costsCmsWithHeap(2.95e-8 → 3.35e-7/s)warningsadds assumed data facts (DDSketch range, in-order arrival)Follow-ups
planner_fuzztests fail after main's cost refits. They fail on main too (todo!). They are planner findings, not printer ones.issue_891_filtered_rate_reads_the_grouped_rateandfinds_issue_902_filter_on_group_key_not_reading_the_grouped_result: the filtered query still reads the shared grouped state, but the planner has no candidate that filters the finished grouped result ([Performance] No candidate filters a finished grouped result on a group key; filtered queries re-aggregate filtered states instead #891's remaining gap). It filters states and re-merges or re-aggregates them instead. Under measured costs that path costs +0.0925/s for [Performance] No candidate filters a finished grouped result on a group key; filtered queries re-aggregate filtered states instead #891 (Filter +Aggregate sum) and +0.080/s for A filtered query (city = 'NYC') doesn't read its group from a grouped summary another query builds #902 (Filter +SummaryMerge). The filter-the-result witness costs +0.00004/s and +0.00001/s. Both gaps exceed the 1% tolerance, and the MILP objective equalsplan_cost, so this is a missing candidate, not a costing mismatch. Both tests' doc comments point at [Performance] No candidate filters a finished grouped result on a group key; filtered queries re-aggregate filtered states instead #891, which tracks the fix.sketch_rollup_witness_costs_for_a_grouped_quantile: with raw data kept, the exact grouped quantile is now cheaper than any KLL, so there is no sketch to roll up. The test needs a workload whose plan reads a sketch (without raw data, the generated ad hoc workload is infeasible). That workload is being reworked in a separate PR, so this PR leaves the test as it is.RejectionCausecleanup, the integration-test andsummary_sharingpins), and the restacks of test(devtools): plan snapshots for 33 small single-purpose workloads (#1278) #1284 and feat(devtools): asap_planner text output is terse by default; --verbose prints the details (#1261) #1276 onto this head.case.toml.History: earlier rounds (port, round 1, rebase onto #1238 round 1, round 2 verification)
Round 1 review fixes (
0bc02af46)✓, the DDSketch one's showed "no guarantee", when Pass 2 failed both withValuesPerEvaluationUnknown)LogicalASAPMemoCandidates::failing_logical_edges, filled before dead endpoints are filtered.logical_edges_intoreads it. Deleted: the rule re-implementation, the fallback string, theErrorMetricsOfMemoandevidenceparameters, and devtools'asap-accuracydependency. Test first:failing_logical_edges_show_the_reason_pass_2_recorded(the review's workload) failed atafdc971f7and passes now, in text and JSON. The viewer'smemoLogicalEdgesshows the same reason (checked on that workload's document).chain_off_the_evaluation_gridexported for devtoolspub(crate)again, as on baseenum LogicalEdgeStatus { Holds, NoEdgeOtherTheta, Fails(&RootPruneReason) }, formatted once byLogicalEdgeStatus::rejectionn1 AtIngestion retention 3600000 ms; the view list is derived once and shared by text and JSON{}{:.6e}, e.g.objective 3.990105e-6/snext tocost_per_second: 3.990105e-6GroupPropertiesfieldsresult_kind,shareable_when_equal(text:not shareable when equalwhen false) andaggregate_coverage(covers G0 through [SummaryAgg DDSketch] selecting [...])QueryLanguage::MetricsQLlowers withasap_frontend_metricsql(lower_metricsql_roots) and is named"metricsql"; the review's three-query workload plans (exit 0)pass1_failure_*PlanningStagesError::Pass1document path has a unit test again (a_pass1_failure_still_writes_stage0_and_the_error, in theasap_plannerbin)Rebase onto #1238 round 1 (
f2411a9b7)git rebase --onto b8d6ffb04 55f0ef67d: the port and the round-1 fixes are now410761e65anddbcd74611, plus one adaptation commitf2411a9b7.memo-small.jsonandmemo-enumeration-small.json(deleted here, modified by refactor(stage3): constraint (K) per execution and metric; sign-conditioned DDSketch guarantee, classic HLL certificate from the source's distinct bound (#1207 PR 8) #1238). Took the delete: the viewer reads the new document and its fixtures arep90-kll.jsonandp90-workload.json.AccuracyRules::composeandRootLimitsare internal to Stage 3's (K); devtools reads onlySelection::accepted_accuracy_per_query, whoseaccepted_metricnow comes fromCandidateForMemoGroup::required_accuracy. Nothing to change.failure_probability_per_output_value(renamed;Nonewithout a δ): devtools never called it. Pass 2 still recordsValuesPerEvaluationUnknownfor a δ over the whole result withCandidateForMemoGroup::required_accuracy(): devtools prints the per-inputrequired_accuracy(requires=[...], JSONrequired_accuracy), which is the field the method reads. Kept per input, since a readout's line names its input.guarantee/ddsketch.rs: a DDSketch quantile over values not of one sign now fails its readout edge withNoGuarantee. Adapted:NoGuarantee's text said "the producer's summary type has no guarantee for the readout's statistic", which is wrong for this case, for a randomized sketch under an exact target (δ 0) and for HLL. It now readsthe readout's error has no bound at the failure probability its queries require: no metric, or no guarantee known to hold there (a randomized sketch under an exact target's δ 0; HLL, whose failure probability is unknown; DDSketch over values not of one sign).theoretical_guaranteemade test-only: devtools has noasap-accuracydependency since round 1.Round 2 verification (at
f2411a9b7)Pass 2's
failing_logical_edgesagainst what Pass 2 decided, on vpeu and three more workloads (all with--run-until stage3 --printing-full-candidates, text and JSON, exit 0). For each workload a script checks that: (1) every edge's ✓/✗ and reason are identical in text and JSON; (2) every pruned candidate's root cause (pruned_candidates[].causes) appears as a failing edge into its consumer, on its input, with the same text; (3) every surviving candidate has, per input, a holding edge from a surviving producer; (4) when every edge on an input of a pruned candidate fails, those reasons are among its causes. The reasons were also checked by hand against the workload:series_countundeclared; q0.5 without δ)ValuesPerEvaluationUnknown; 7 into the DDSketch q0.5 readout:NoGuarantee; 3 into the KLL q0.5 readout:BelowRequiredAccuracyRank ≤ 0.01latencyis a gauge of unknown sign (#1238's DDSketch sign condition); k = 26, 52, 132 miss rank 0.01quantile_over_time(0.9, m[30s])every 15 s and every 10 s, rank 0.05TimeRange 30sfrom the 10 s and 15 s chains:ChainWidthDoesNotDivideEvaluationGrid(grid 5,000 ms); 7 DDSketch readout edges and 1Projectedge over the DDSketch readout:MetricRule(accepts Rank, not Relative); 2 KLL readout edges:BelowRequiredAccuracyat rank 0.05a_chain_whose_width_does_not_divide_the_readers_grid_fails_its_edge)quantile_over_time(0.99, m[5m]) / quantile_over_time(0.5, m[5m]), relative 0.05,mnon-negativeProjectedges over the KLL readouts:MetricRule(accepts Relative, not Rank); 30 + 30 DDSketch edges:BelowRequiredAccuracyat levels 0.02 … 0.001dead_candidates_are_pruned_and_listed_before_chain_groups)g(sign unknown) and overh(non-negative), relative 0.02 at δ 0.01g's DDSketch readout:NoGuarantee; 2 intoh's:BelowRequiredAccuracyRelative ≤ 0.02; 14 KLL readout edges and the 2Projectedges over the KLL readouts:MetricRuleg, only α = 0.1 and 0.05 overhfailing_logical_edges,edges,pruned,evaluation_grid_of_group, the physicalsatisfies_*flags, Stage 2's and Stage 3's pruned lists andSelection; it callsMemo::producers(which producers a consumer reads) andasap_cost::plan_cost. Noasap-accuracydependency, no edge rule, andchain_off_the_evaluation_gridstayspub(crate).memoLogicalEdgesrenders every edge (93 + 212 + 224 + 124) as✓/✗ #producer: <rejection>with the document's own rejection string (0 mismatches), andvalidateMemoreports no errors. It prints the JSON'srejection; it derives nothing.